package com.gm.wj.dao;

import com.gm.wj.entity.SysBanner;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SysBannerDAO extends JpaRepository<SysBanner,Integer> {
    SysBanner findById(int id);

    @Query(value = "select * from sys_banner  where display = ?1 and is_delete = 0",nativeQuery = true)
    List findByDisplay(int i);

    // 多条件模糊查询
    @Query(value = "select * from sys_banner  where  (?1 is null or display = ?1) and (?2 is null or name like ?2) and (?3 is null or position like ?3) and is_delete = 0",nativeQuery = true)
    List<SysBanner> find(String queryKey1, String queryKey2, String queryKey3);

    // 广告页查询
    @Query(value = "select * from sys_banner  where display = 1 and is_delete = 0 ORDER BY weight ASC;",nativeQuery = true)
    List<SysBanner> findBannerByDisplay();

}
